home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / timeline / grid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  7.5 KB  |  265 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23. /* $Header: /Source/Media/collab/TimeLine/RCS/grid.c,v 1.0 91/09/30 16:57:29 chua Exp Locker: drapeau $ */
  24. /* $Log:    grid.c,v $
  25.  * Revision 1.0  91/09/30  16:57:29  chua
  26.  * Update to version 1.0
  27.  * 
  28.  * Revision 0.42  91/09/19  17:28:48  chua
  29.  * Make sure that variables are initialized properly.  Change formatting slightly,
  30.  * so that (if, for, while) statements with only one statement in them will not have
  31.  * braces.
  32.  * 
  33.  * Revision 0.41  91/07/18  15:05:13  chua
  34.  * 
  35.  * 
  36.  * Revision 0.40  91/07/18  15:01:38  chua
  37.  * This file contains the menu handlers for the grid menu (under the edit menu button).
  38.  * It also contains the DrawGrid routine, which will draw the grid lines on the canvas
  39.  * according to the spacing specified by the user (using the grid menu).
  40.  *  */
  41.  
  42. static char gridrcsid[] = "$Header: /Source/Media/collab/TimeLine/RCS/grid.c,v 1.0 91/09/30 16:57:29 chua Exp Locker: drapeau $";
  43.  
  44. #include "main.h"
  45.  
  46. /*
  47.  * Menu handler for `GridMenu (Grid Off)'.
  48.  */
  49. Menu_item GridOffHandler(item, op)
  50.      Menu_item    item;
  51.      Menu_generate    op;
  52. {
  53.   TimeLineFramePtr tlFrame;
  54.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  55.  
  56.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  57.   switch (op) 
  58.   {
  59.    case MENU_DISPLAY:
  60.     break;
  61.    case MENU_DISPLAY_DONE:
  62.     break;
  63.    case MENU_NOTIFY:
  64.     tlFrame->gridSpacing = 0;
  65.     DrawCanvasRepaintHandler(tlFrame->TimeLine_window->DrawCanvas, tlFrame->paintWinDraw, 
  66.                  tlFrame->dpyDraw, tlFrame->xidDraw, NULL);
  67.     break;
  68.    case MENU_NOTIFY_DONE:
  69.     break;
  70.   }
  71.   return item;
  72. }
  73.  
  74. /*
  75.  * Menu handler for `GridMenu (5 pixel spacing)'.
  76.  */
  77. Menu_item FivePixelHandler(item, op)
  78.      Menu_item    item;
  79.      Menu_generate    op;
  80. {
  81.   TimeLineFramePtr tlFrame;
  82.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  83.  
  84.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  85.   switch (op) 
  86.   {
  87.    case MENU_DISPLAY:
  88.     break;
  89.    case MENU_DISPLAY_DONE:
  90.     break;
  91.    case MENU_NOTIFY:
  92.     tlFrame->gridSpacing = 5;
  93.     DrawCanvasRepaintHandler(tlFrame->TimeLine_window->DrawCanvas, tlFrame->paintWinDraw, 
  94.                  tlFrame->dpyDraw, tlFrame->xidDraw, NULL);
  95.     break;
  96.    case MENU_NOTIFY_DONE:
  97.     break;
  98.   }
  99.   return item;
  100. }
  101.  
  102. /*
  103.  * Menu handler for `GridMenu (10 pixel spacing)'.
  104.  */
  105. Menu_item TenPixelHandler(item, op)
  106.      Menu_item    item;
  107.      Menu_generate    op;
  108. {
  109.   TimeLineFramePtr tlFrame;
  110.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  111.  
  112.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  113.   switch (op) 
  114.   {
  115.    case MENU_DISPLAY:
  116.     break;
  117.    case MENU_DISPLAY_DONE:
  118.     break;
  119.    case MENU_NOTIFY:
  120.     tlFrame->gridSpacing = 10;
  121.     DrawCanvasRepaintHandler(tlFrame->TimeLine_window->DrawCanvas, tlFrame->paintWinDraw, 
  122.                  tlFrame->dpyDraw, tlFrame->xidDraw, NULL);
  123.     break;
  124.    case MENU_NOTIFY_DONE:
  125.     break;
  126.   }
  127.   return item;
  128. }
  129.  
  130. /*
  131.  * Menu handler for `GridMenu (20 pixel spacing)'.
  132.  */
  133. Menu_item TwentyPixelHandler(item, op)
  134.      Menu_item    item;
  135.      Menu_generate    op;
  136. {
  137.   TimeLineFramePtr tlFrame;
  138.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  139.  
  140.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  141.   switch (op) 
  142.   {
  143.    case MENU_DISPLAY:
  144.     break;
  145.    case MENU_DISPLAY_DONE:
  146.     break;
  147.    case MENU_NOTIFY:
  148.     tlFrame->gridSpacing = 20;
  149.     DrawCanvasRepaintHandler(tlFrame->TimeLine_window->DrawCanvas, tlFrame->paintWinDraw, 
  150.                  tlFrame->dpyDraw, tlFrame->xidDraw, NULL);
  151.     break;
  152.    case MENU_NOTIFY_DONE:
  153.     break;
  154.   }
  155.   return item;
  156. }
  157.  
  158. /*
  159.  * Menu handler for `GridMenu (30 pixel spacing)'.
  160.  */
  161. Menu_item ThirtyPixelHandler(item, op)
  162.      Menu_item    item;
  163.      Menu_generate    op;
  164. {
  165.   TimeLineFramePtr tlFrame;
  166.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  167.  
  168.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  169.   switch (op) 
  170.   {
  171.    case MENU_DISPLAY:
  172.     break;
  173.    case MENU_DISPLAY_DONE:
  174.     break;
  175.    case MENU_NOTIFY:
  176.     tlFrame->gridSpacing = 30;
  177.     DrawCanvasRepaintHandler(tlFrame->TimeLine_window->DrawCanvas, tlFrame->paintWinDraw, 
  178.                  tlFrame->dpyDraw, tlFrame->xidDraw, NULL);
  179.     break;
  180.    case MENU_NOTIFY_DONE:
  181.     break;
  182.   }
  183.   return item;
  184. }
  185.  
  186. /*
  187.  * Menu handler for `GridMenu (40 pixel spacing)'.
  188.  */
  189. Menu_item FortyPixelHandler(item, op)
  190.      Menu_item    item;
  191.      Menu_generate    op;
  192. {
  193.   TimeLineFramePtr tlFrame;
  194.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  195.  
  196.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  197.   switch (op) 
  198.   {
  199.    case MENU_DISPLAY:
  200.     break;
  201.    case MENU_DISPLAY_DONE:
  202.     break;
  203.    case MENU_NOTIFY:
  204.     tlFrame->gridSpacing = 40;
  205.     DrawCanvasRepaintHandler(tlFrame->TimeLine_window->DrawCanvas, tlFrame->paintWinDraw, 
  206.                  tlFrame->dpyDraw, tlFrame->xidDraw, NULL);
  207.     break;
  208.    case MENU_NOTIFY_DONE:
  209.     break;
  210.   }
  211.   return item;
  212. }
  213.  
  214. /*
  215.  * Menu handler for `GridMenu (50 pixel spacing)'.
  216.  */
  217. Menu_item FiftyPixelHandler(item, op)
  218.      Menu_item    item;
  219.      Menu_generate    op;
  220. {
  221.   TimeLineFramePtr tlFrame;
  222.   TimeLine_window_objects * ip = (TimeLine_window_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  223.  
  224.   tlFrame = TimeLineWindow[xv_get(ip->controls, PANEL_CLIENT_DATA)];
  225.   switch (op) 
  226.   {
  227.    case MENU_DISPLAY:
  228.     break;
  229.    case MENU_DISPLAY_DONE:
  230.     break;
  231.    case MENU_NOTIFY:
  232.     tlFrame->gridSpacing = 50;
  233.     DrawCanvasRepaintHandler(tlFrame->TimeLine_window->DrawCanvas, tlFrame->paintWinDraw, 
  234.                  tlFrame->dpyDraw, tlFrame->xidDraw, NULL);
  235.     break;
  236.    case MENU_NOTIFY_DONE:
  237.     break;
  238.   }
  239.   return item;
  240. }
  241.  
  242. /* 
  243.  * This function will draw the grid lines on the canvas.
  244.  * First, it will set the line width to 1 pixel wide and the foreground color of the grid lines to white (to differentiate from the playback head).
  245.  * It will then perform a loop to draw the grid lines.
  246.  * The line width is then set back to 2.
  247.  */
  248. void DrawGrid(tlFrame)
  249.   TimeLineFramePtr tlFrame;
  250. {
  251.   int i;  
  252.  
  253.   if (tlFrame->gridSpacing > 0) 
  254.   {
  255.     SetLineAttributes(tlFrame, 1);
  256.     XSetForeground(tlFrame->dpyDraw, tlFrame->gc, (long)tlFrame->pixelTable[White]);
  257.     for (i=0; i < tlFrame->TimeLineLength; i += tlFrame->gridSpacing) /* Draw the grid lines */
  258.       XDrawLine(tlFrame->dpyDraw, tlFrame->xidDraw, tlFrame->gc, i, 0,
  259.         i, tlFrame->numberOfApps * 72 + FirstCableYPosition);
  260.     SetLineAttributes(tlFrame, 2);
  261.   }
  262. }
  263.  
  264.  
  265.